package com.edu.scnu.game;

import java.awt.CardLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;

import com.edu.scnu.controller.GameListener;
import com.edu.scnu.controller.GameThread;
import com.edu.scnu.show.GameJFrame;
import com.edu.scnu.show.GameMainJPanel;
import com.edu.scnu.show.MenuPanel;

public class GameStart {
	/**
	 * 程序的唯一入口
	 */
	public static void main(String[] args) {
		GameJFrame gj = new GameJFrame();
		/*
		 * 实例化面板，注入到jframe中
		 */
		GameMainJPanel jp = new GameMainJPanel();
		// 实例化监听
		GameListener listener = new GameListener();
		// 实例化主线程
		GameThread th = new GameThread();
		/* 注入 */
		CardLayout cardLayout = new CardLayout();
		JPanel mainPanel = new JPanel(cardLayout);
		MenuPanel menuPanel = new MenuPanel(cardLayout, mainPanel);
		menuPanel.setjPanel(jp);
		menuPanel.setThread(th);
		gj.setKeyListener(listener);
		gj.setCardLayout(cardLayout);
		gj.setMenuPanel(menuPanel);
		gj.setMainPanel(mainPanel);
		gj.setJpanel(jp);
		gj.start();
		gj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	
}
